﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebSocketClient.aspx.cs" Inherits="Derrick.Web.WebSocketClient" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

    <script type="text/javascript">
        function connect() {
            var ws = new WebSocket("ws://tardis:1802");
            ws.onopen = function () {
                alert("About to send data");
                ws.send("Hello World"); // I WANT TO SEND THIS MESSAGE TO THE SERVER!!!!!!!!
                alert("Message sent!");
            };

            ws.onmessage = function (evt) {
                alert("About to receive data");
                var received_msg = evt.data;
                alert("Message received = " + received_msg);
            };
            ws.onclose = function () {
                // websocket is closed.
                alert("Connection is closed...");
            };
        };


    </script>

    <title>Web Socket Client</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <a href="#" onclick="connect()">Click here to start</a>
    </div>
    </form>
</body>
</html>
